package learn_0324;

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        String inputStr = in.nextLine();
        String s =  in.nextLine();
        char target = (s.charAt(0));
        char target_big = '*';
        boolean numFlag = false;
        if ('0'<=target && target <= '9'){
            numFlag = true;
        }else{
            if(s.charAt(0)>='a'){
                target_big = (char)(s.charAt(0)-32);
            }else{
                target_big = (char)(s.charAt(0)+32);
            }
        }
        int num = 0 ;
        for(int i = 0;i<inputStr.length();i++){
            if(numFlag){
                if (inputStr.charAt(i)== target){
                    num +=1;
                }
            }else{
                if ((inputStr.charAt(i)== target) || (inputStr.charAt(i)==target_big)){
                    num +=1;
                }
            }

        }
        System.out.print(num);
    }
}